package service

import (
	"encoding/json"
	"net/http"

	"github.com/cy18cn/dapr-demo/g"
	"github.com/julienschmidt/httprouter"
)

func Save(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {

}

func Get(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {
	ctx := req.Context()
	item, err := g.DaprClient.GetState(ctx, "RedisStore", "key")
	if g.CheckErr(w, err) {
		return
	}

	res, _ := json.Marshal(&g.Response{
		Code: 1,
		Msg:  "Success",
		Resp: item,
	})

	w.Write(res)
}
